const { createHash } = require("crypto");
const { rootID, developerID, masterID } = require("../generator");

module.exports = {
  up: (queryInterface, Sequelize) => {
    return queryInterface.bulkInsert(
      "t_user",
      [
        {
          id: rootID,
          account: "root",
          name: "root",
          password: createHash("md5")
            .update("123456")
            .digest("hex"),
          email: "shiqifeng2000@gmail.com",
          mobile: "15901594094",
          create_user_id: rootID,
          modify_user_id: rootID,
          create_time: new Date(),
          modify_time: new Date()
        },
        {
          id: developerID,
          account: "developer",
          name: "developer",
          password: createHash("md5")
            .update("123456")
            .digest("hex"),
          email: "shiqifeng2000@gmail.com",
          mobile: "15901594094",
          create_user_id: rootID,
          modify_user_id: rootID,
          create_time: new Date(),
          modify_time: new Date()
        },
        {
          id: masterID,
          account: "master",
          name: "master",
          password: createHash("md5")
            .update("123456")
            .digest("hex"),
          email: "shiqifeng2000@gmail.com",
          mobile: "15901594094",
          create_user_id: rootID,
          modify_user_id: rootID,
          create_time: new Date(),
          modify_time: new Date()
        }
      ],
      {}
    );
  },

  down: (queryInterface, Sequelize) => {
    return queryInterface.bulkDelete("t_user", null, {});
  }
};
